package cn.virens.service.impl.base;

import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.virens.CacheKeys;
import cn.virens.database.mysql.mapper.base.BaseAreaMapper;
import cn.virens.service.inter.base.BaseAreaService;

/**
 * 区域数据接口服务
 * 
 * @作者   : virens
 * @创建时间 :2018年2月28日 上午9:19:53
 */
@Service
public class BaseAreaServiceImpl implements BaseAreaService {
	private final Logger logger = LoggerFactory.getLogger(getClass());

	private @Autowired BaseAreaMapper mBaseAreaMapper;

	@Override
	@Transactional(readOnly = true)
	@Cacheable(value = CacheKeys.CACHE_AREAS, key = "#p0 + ':' + #p1")
	public List<Map<String, Object>> select(String code, String pcode) {
		return mBaseAreaMapper.selectList(code, pcode);
	}

	@Override
	@CacheEvict(value = CacheKeys.CACHE_AREAS, allEntries = true)
	public void clear() {
		logger.debug("已经清空区域查询缓存!");
	}
}
